package com.mec.web.y2012.coreservlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.mec.beans.y2012.coreservlet.InsuranceInfo;

/**
 * Servlet implementation class SubmitInsuranceInfoServlet
 */
@WebServlet("/SubmitInsuranceInfoServlet")
public class SubmitInsuranceInfoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public SubmitInsuranceInfoServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		InsuranceInfo info = new InsuranceInfo();
		BeanUtilities.populateBean(info, request);
		//
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		String title = "Insurance Info for " + info.getName();
		//
		out.println(Constants.docType + ServletUtilities.headWithTitle(title) + 
				"<body bgcolor=\"#fdf5e6\">\n<center><h1>" + title + 
				"</h1></center>\n<ul><li>EmployID: " + info.getEmployeeID() + 
				"</li><li>Number of Children: " + info.getNumChildren() +
				"</li><li>Married? : " + info.isMarried() +
				"</li></ul></body></html>"
				);
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	private static final Logger logger =
			Logger.getLogger(SubmitInsuranceInfoServlet.class);
}
